feat: add session profiles (custom CLI environment per session)#39
Merged
feat: add session profiles (custom CLI environment per session)#39
Conversation
- Add CommandProfile type (executable, extraArgs, envVars, profileName) - Extend SessionInfo with binaryName, extraArgs, profileName, envVars - DB migrations v5-v7: binary_name, extra_args, preset_name, env_vars columns - MIGRATIONS map changed from single strings to string[] for multi-statement safety
- shell-env.ts: load user login+interactive env once via zsh -l -c, so PATH, API keys, and .zshrc vars are available to agent processes - PtyManager: accept shellEnvProvider (injectable for tests) and envVarsStr (newline-separated KEY=VALUE pairs from profile) - ClaudeAdapter / agent-registry: thread extraArgs through to buildStartArgs and buildResumeArgs - session-lifecycle: use session.binaryName for spawn, parse extraArgs
- sessions:create resolves profileId -> CommandProfile, stores binaryName/extraArgs/profileName/envVars in DB - pty:create reads profile fields from session record and passes to PtyManager - sessionStore and Sidebar forward profileId through onConfirm chain
- SettingsPanel: Profiles section with add/edit/delete, fields for executable, extra args, and env vars (newline-separated KEY=VALUE) - NewSessionDialog: profile dropdown (loads independently of branch fetch so a git error can't hide it), forwards profileId on confirm - SessionListItem: show profile name in accent color on sub-line, branch truncates to make room - TerminalView: silence pty:input errors on dead PTY sessions
- DB migrations v5/v6/v7 — columns exist and default to null - createSession stores/returns profileName and envVars correctly - PtyManager: shell env merging, CLAUDECODE stripping, binaryName override, extraArgs/envVars injection - ClaudeAdapter: extraArgs appended in both start and resume args
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
~/.zshrc,~/.zprofile) into every PTY session, fixing missing PATH/API keys in Electron-launched processesWhat changed
Data model
CommandProfiletype withname,executable,extraArgs,envVarsfieldsSessionInfoextended withbinaryName,extraArgs,profileName,envVarsbinary_name,extra_args,preset_name,env_varscolumns to sessionsShell environment
shell-env.ts: runs$SHELL -l -c 'source ~/.zshrc; printenv'once at startup and caches the result; injected into every PTY spawn so tools on PATH and env vars set in dotfiles are availableenvVars(newline-separatedKEY=VALUE) are overlaid on top, allowing per-session overrides likeCLAUDE_CONFIG_DIRPTY / agent layer
PtyManager.createacceptsbinaryNameOverride,extraArgsStr, andenvVarsStr;shellEnvProvideris injectable for testsClaudeAdapterappendsextraArgsto bothbuildStartArgsandbuildResumeArgssession-lifecycleusessession.binaryName ?? agentTypefor the spawn binaryIPC
sessions:createresolvesprofileId→CommandProfileand stores all profile fields in the DBpty:createreads the stored profile fields and passes them toPtyManagerpty:inputerrors on dead PTY sessions are now silenced (.catch(() => {}))UI
Testing
createSessionwithprofileName/envVars,PtyManagerenv merging andenvVarsStrinjection,ClaudeAdapterextraArgsin start and resumeshell-env.tsparseEnvOutputhas 7 unit tests covering edge cases (noise lines, multiline values, empty input)